import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:hm_show_flutter/style/style.dart';

class AppLoadingDialog extends Dialog {
  final String text;

  AppLoadingDialog({this.text});

  @override
  Widget build(BuildContext context) {
    return new Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: Center(
        //保证控件居中效果
        child: SizedBox(
          width: 120.0,
          height: 120.0,
          child: Container(
            decoration: ShapeDecoration(
              color: Color(0xffffffff),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(
                  Radius.circular(8.0),
                ),
              ),
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                SpinKitCircle(
                  size: ScreenUtil.instance.setWidth(90.0),
                  color: AppColors.mainColor,
                ),
                Padding(
                  padding: const EdgeInsets.only(
                    top: 20.0,
                  ),
                  child: text == null
                      ? Container()
                      : Text(
                          text,
                          style: TextStyle(fontSize: 12.0),
                        ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
